import { defineStore } from "pinia";
import type { User } from "../types";

export const countStore = defineStore("count", {
    state: () => ({ count: 0 }),
    getters: {
        getCount: (state) => {
            return state.count;
        }
    },
    actions: {
        increament() {
            this.count++;
        },
        plusCount(amount: number) {
            this.count += amount;
        }
    }
})

const user: User = { name: "admin", age: 20 };

export const userStore = defineStore("user", {
    state: () => (user),
    getters: {
        getName(): string {
            return this.name;
        },
        getAge(): number {
            return this.age;
        }
    },
    actions: {
        setAge(age: number) {
            this.age = age;
        }
    }
})
